package com.prism.moodme.app;


import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.BoxLayout;
import java.awt.ComponentOrientation;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.sql.SQLException;

import javax.swing.JSplitPane;

import com.prism.moodme.datastore.AccessDataStore;

public class MainFrame extends JFrame {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private SearchPane searchPane = null;
	private ResultPane resultPanel = null;


	private static Dimension appSize;  //  @jve:decl-index=0:
	private JSplitPane jSplitPane = null;
	/**
	 * This is the default constructor
	 */
	public MainFrame() {
		super("MoodMe");
		initialize();

        addWindowListener(new WindowAdapter( ) {
            public void windowClosing(WindowEvent e) {
            	AccessDataStore.shutdown();
            	System.exit(0);
            }
        });
	}

	/**
	 * This method initializes this
	 *
	 * @return void
	 */
	private void initialize() {

		this.setName("Moodme beta");
		this.setSize(new Dimension(1029, 700));
		this.setPreferredSize(new Dimension(1029, 700));
		this.setResizable(false);
		this.setContentPane(getJContentPane());
		this.setTitle("MoodMe");
	}

	/**
	 * This method initializes jContentPane
	 *
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(new BoxLayout(getJContentPane(), BoxLayout.Y_AXIS));
			jContentPane.setSize(this.getSize());
			jContentPane.add(getJSplitPane(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes SearchPanel
	 *
	 * @return javax.swing.JPanel
	 */
	private SearchPane getSearchPane() {
		if (searchPane == null) {
			searchPane = new SearchPane(this);
		}
		return searchPane;
	}

	/**
	 * This method initializes ResultPanel
	 *
	 * @return javax.swing.JPanel
	 */
	public ResultPane getResultPane() {
		if (resultPanel == null) {
			resultPanel = new ResultPane();
		}
		return resultPanel;
	}

	/**
	 * This method initializes jSplitPane
	 *
	 * @return javax.swing.JSplitPane
	 */
	private JSplitPane getJSplitPane() {
		if (jSplitPane == null) {
			jSplitPane = new JSplitPane();
			jSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
			jSplitPane.setDividerLocation(150);
			jSplitPane.setDividerSize(5);
			jSplitPane.setEnabled(false);
			jSplitPane.setBottomComponent(getResultPane());
			jSplitPane.setTopComponent(getSearchPane());
		}
		return jSplitPane;
	}


}  //  @jve:decl-index=0:visual-constraint="10,10"
